package com.why.sharding.controllr;

import com.why.sharding.entity.Order;
import com.why.sharding.service.OrderService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description:
 * @author: wanghongyu | stan.wang@paytm.com
 * @create: 2022/01/18
 **/
@RestController
public record OrderController(OrderService orderService) {

    /**
     * 功能描述： 实现新增订单
     * @param order 订单的实体
     */
    @PostMapping("saveOrder")
    public void saveOrder(@RequestBody Order order){
        orderService.saveOrder(order);
    }

    /**
     * 功能描述： 根据订单ID来获取订单数据
     * @param orderId 订单流水ID
     * @return 返回查询结果
     */
    @PostMapping("getOrderByOrderId")
    public Order getOrderByOrderId(Long orderId){
        return orderService.getOrderByOrderId(orderId);
    }

}
